/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package networkrespnse;

import core.ParameterDecoder;
import utils.Utils;

/**
 *
 * @author Kvest
 */
public class DriverMessageResponse extends Response
{
    public String text;
    public String theme;
    
    public DriverMessageResponse(byte[] data)
    {
        super(DRIVER_MESSAGE_RESPONSE);
        text = "";
        theme = "";
        
        parse(data);
    }
    
    protected void parse(byte[] data)
    {
        byte[] body = ParameterDecoder.getTransferBody(data);
        
        byte[] temp = new byte[4];
        int index = 0;
        for (int i=0;i<4;i++)
        {
                temp[i] = body[index++];
        }
        index += Utils.byteToInt(temp);
        
        //text
        temp = new byte[4];
        for (int i=0;i<4;i++)
        {
                temp[i] = body[index++];
        }
        int size = Utils.byteToInt(temp);
        temp = new byte[size];
        for (int i=0;i<size;i++)
        {
                temp[i] = body[index++];
        }
        text = Utils.byteToString(temp);       
         //theme
        temp = new byte[4];
        for (int i=0;i<4;i++)
        {
                temp[i] = body[index++];
        }
        size = Utils.byteToInt(temp);
        temp = new byte[size];
        for (int i=0;i<size;i++)
        {
                temp[i] = body[index++];
        }
        theme = Utils.byteToString(temp);      
    }

    public String getText() 
    {
        return text;
    }

    public String getTheme() 
    {
        return theme;
    }  
}
